 

package com.zdkj.subway.rca.controller;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.zdkj.common.core.util.R;


import com.zdkj.subway.rca.entity.SwCkBackElectronicBill;
import com.zdkj.subway.rca.service.SwCkBackElectronicBillService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 银行电子账单表
 *
 * @author stw
 * @date 2020-09-25 15:55:16
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swckbackelectronicbill" )
@Api(value = "swckbackelectronicbill", tags = "银行票据单管理-银行电子账单-银行电子账单表管理")
public class SwCkBackElectronicBillController {

    private final SwCkBackElectronicBillService swCkBackElectronicBillService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param
     * @return
     */
    @ApiOperation(value = "分页查询,bankType:建行：ccb，中行：boc", notes = "分页查询,bankType:建行：ccb，中行：boc")
    @GetMapping("/page" )
    public R getSwCkBackElectronicBillPage(Page page,String bankType, String startDate,String endDate,String transactionAmounStart,String transactionAmounEnd,String accountName) {
        SwCkBackElectronicBill swCkBackElectronicBill = new SwCkBackElectronicBill();

        if("ccb".equals(bankType)){
            swCkBackElectronicBill.setBankName("建设银行");			
        } else {
            swCkBackElectronicBill.setBankName("中国银行");
        }

        Long transactionAmounStartLong = null;
        if (StringUtils.isNotEmpty(transactionAmounStart)) {
            Double transactionAmounStartDouble = (Double.parseDouble(transactionAmounStart) * 100);
            transactionAmounStartLong = transactionAmounStartDouble.longValue();
        }

        Long transactionAmounEndLong = null;
        if(StringUtils.isNotEmpty(transactionAmounEnd)) {
            Double transactionAmounEndDouble = (Double.parseDouble(transactionAmounEnd) * 100);
            transactionAmounEndLong = transactionAmounEndDouble.longValue();
        }
        if (StringUtils.isNotEmpty(accountName)) {
		 
		}

        return R.ok(swCkBackElectronicBillService.page(page, Wrappers.query(swCkBackElectronicBill).lambda().ge(StringUtils.isNotEmpty(startDate),SwCkBackElectronicBill::getRecordTime, startDate).le(StringUtils.isNotEmpty(endDate),SwCkBackElectronicBill::getRecordTime, endDate)
                .ge(StringUtils.isNotEmpty(transactionAmounStart),SwCkBackElectronicBill::getTransactionAmoun, transactionAmounStartLong).le(StringUtils.isNotEmpty(transactionAmounEnd),SwCkBackElectronicBill::getTransactionAmoun, transactionAmounEndLong)
                .like(StringUtils.isNotEmpty(accountName),SwCkBackElectronicBill::getAccountName, accountName)
		        .orderByDesc(SwCkBackElectronicBill::getRecordTime)));

    }


}
